<template>
    <div>
        <el-form :inline="true" :model="params" class="demo-form-inline">
            <el-form-item label="挂号费用名称">
                <el-input v-model="params.subRegisteredfeeName" placeholder="挂号费用子名称"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="search">查询</el-button>
                <el-button type="primary" @click="toadd">添加</el-button>
                <el-button type="primary" @click="pldel">批量删除</el-button>
            </el-form-item>
        </el-form>

        <el-table
                :data="pageResult.records"
                border
                style="width: 100%"
                @selection-change="handleSelectionChange">
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    fixed
                    prop="regSubId"
                    label="编号">
            </el-table-column>
            <el-table-column
                    prop="subRegisteredfeeName"
                    label="挂号费用名称">
            </el-table-column>
            <el-table-column
                    prop="subRegisteredfeeFee"
                    label="金额">
            </el-table-column>
            <el-table-column
                    fixed="right"
                    label="操作">
                <template slot-scope="scope">
                    <!--<el-button @click="toupdate(scope.row.regId)" type="text" size="small">编辑</el-button>-->
                    <el-button @click="del(scope.row.regSubId)" type="text" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-footer class="case-exam-footer">
            <el-pagination
                    background
                    layout="prev, pager, next"
                    :total="pageResult.total"
                    :page-size="pageResult.size"
                    class="pagination"
                    @current-change="handleIndexChange"
            >
            </el-pagination>
        </el-footer>


        <el-dialog title="挂号费管理" :visible.sync="dialogFormVisibleAdd">
            <el-form :model="HisRegisteredfeeSubEntity">
                <el-form-item label="挂号费用名称">
                    <el-input v-model="HisRegisteredfeeSubEntity.subRegisteredfeeName" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="金额">
                    <el-input type="number" v-model="HisRegisteredfeeSubEntity.subRegisteredfeeFee" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisibleAdd = false">取 消</el-button>
                <el-button type="primary" @click="add()">确 定</el-button>
            </div>
        </el-dialog>



        <el-button @click="returnBtn">返回</el-button>
    </div>
</template>

<script>


    import HisRegisteredfeeSub from '../../model/mfy/HisRegisteredfeeSub.js'
    const hisRegisteredfeeSub =HisRegisteredfeeSub.getInstance();


    export default {
        name: "RegisteredfeeSub.vue",
        props:['regId'],
        data(){
            return{
                regIdSub:this.regId,
                pageResult:{}, //page对象
                params:{},     //高级查询参数对象
                delVal:"",
                HisRegisteredfeeSubEntity:{},
                dialogFormVisibleAdd:false,
            }
        },
        watch: {
            regId:function () {
                this.regIdSub=this.regId;
            }
        },
        methods:{
            returnBtn(){
                this.$emit("return")
            },
            list(){
                this.params.regIdSub=this.regIdSub
                hisRegisteredfeeSub.list(this.params).then((response)=>{
                    this.pageResult = response.data.data
                })
            },
            handleIndexChange(index){
                this.params.page = index
                this.list()
            },
            search(){
                this.params.page=1
                this.list()
            },
            del(regSubIds){
                hisRegisteredfeeSub.del(regSubIds).then(()=>{
                    this.list();
                })
            },
            pldel(){
                this.del(this.delVal)
            },
            handleSelectionChange(val){
                var PlDelArray =[];
                val.forEach(i=>{
                    PlDelArray.push(i.regSubId)
                })
                this.delVal=PlDelArray.join(",");
            },
            toadd(){
                this.HisRegisteredfeeSubEntity={}
                this.dialogFormVisibleAdd = true
            },
            add(){
                this.dialogFormVisibleAdd = false
                this.HisRegisteredfeeSubEntity.regId=this.regId
                hisRegisteredfeeSub.add(this.HisRegisteredfeeSubEntity).then(()=>{
                    this.list();
                })
            },
        },
        created() {
            this.list();
        }
    }
</script>

<style scoped>

</style>
